package com.sina.auto.components.AddContentImpl;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;

import static com.sina.auto.components.AddContentImpl.ImageUtil.MergeImage.mergeImage;

public class AddParagraph implements com.sina.auto.components.AddContentInterface.AddParagraph {
    @Override
    public BufferedImage addParaOut(String[] Content) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addParagByMerge(t3, Content);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage addParaOutTitle(String[] Content, String title) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addParagByMergeAddTiltle(t3, Content, title);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage addParaOut(String[] Content, String author, String title) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addParagByMerge(t3, Content, author, title);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }

    @Override
    public BufferedImage addParaOutAuthor(String[] Content, String author) throws Exception {
        BufferedImage t3 = ImageIO.read(new File("template/template3.jpg"));
        BufferedImage img1 = ImageIO.read(new FileInputStream("template/template1.jpg"));
        BufferedImage img2 = AddString.addParagByMergeAddAuthor(t3, Content, author);
        BufferedImage img3 = ImageIO.read(new FileInputStream("template/template2.jpg"));
        BufferedImage[] images = {img1, img2, img3};

        return (mergeImage(images, 2));
    }
}
